﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ZLCMS.Business;
using ZLCMS.Business.DwzFrame;
using ZLCMS.Data.Model;
using NHibernate;
using NHibernate.Criterion;
using ZLCMS.Business.Util;

namespace ZLCMS.Web.SystemManage.Weixin
{
    public partial class ViewMaterialXml : System.Web.UI.Page
    {
        protected FrameHelper _frameHelper;

        protected WxMaterial _matDb;

        protected string _userAccount;

        protected void Page_Load(object sender, EventArgs e)
        {
            _userAccount = UserKit.GetUserAccountFailLogin();

            _frameHelper = new FrameHelper(this);

            //初始化全局变量值
            InitializeGlobalValue();

            //初始化控件值
            InitializeContent();
        }

        private void InitializeContent()
        {
            //页面控件值
            if (!IsPostBack)
            {
            }
        }

        protected void InitializeGlobalValue()
        {
            if (!string.IsNullOrEmpty(Request["uid"]))
            {
                using (ISession session = DotNet.Common.NHibernateUtil.SessionFactoryHelper.CreateSession())
                {
                    try
                    {
                        _matDb = session.CreateCriteria<WxMaterial>().Add(Expression.Eq("OwnerAccount", _userAccount)).Add(Expression.Eq("Id", int.Parse(Request["uid"]))).UniqueResult<WxMaterial>();

                        if (_matDb == null)
                        {
                            throw new Exception("找不到对应信息.");
                        }
                    }
                    catch (System.Exception ex)
                    {
                        _frameHelper.Alert(new ReturnCode() { statusCode = 300, message = "操作出错-" + ex.Message });
                        return;
                    }
                }
            }
        }
    }
}
